/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.utrans.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Gamboa
 */
@Entity
@Table(name = "tarjeta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tarjeta.findAll", query = "SELECT t FROM Tarjeta t"),
    @NamedQuery(name = "Tarjeta.findByCodigoTarjeta", query = "SELECT t FROM Tarjeta t WHERE t.codigoTarjeta = :codigoTarjeta"),
    @NamedQuery(name = "Tarjeta.findByPinTarjeta", query = "SELECT t FROM Tarjeta t WHERE t.pinTarjeta = :pinTarjeta"),
    @NamedQuery(name = "Tarjeta.findBySaldoTarjeta", query = "SELECT t FROM Tarjeta t WHERE t.saldoTarjeta = :saldoTarjeta"),
    @NamedQuery(name = "Tarjeta.findByTipoTarjeta", query = "SELECT t FROM Tarjeta t WHERE t.tipoTarjeta = :tipoTarjeta"),
    @NamedQuery(name = "Tarjeta.findByEstadoTarjeta", query = "SELECT t FROM Tarjeta t WHERE t.estadoTarjeta = :estadoTarjeta")})
public class Tarjeta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name="tarjeta_seq",sequenceName="tarjeta_seq", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE , generator="tarjeta_seq")
    @Basic(optional = false)
    @NotNull
    @Column(name = "codigo_tarjeta")
    private Integer codigoTarjeta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "pin_tarjeta")
    private String pinTarjeta;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "saldo_tarjeta")
    private BigDecimal saldoTarjeta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "tipo_tarjeta")
    private String tipoTarjeta;
    @Size(max = 20)
    @Column(name = "estado_tarjeta")
    private String estadoTarjeta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarjeta")
    private List<RecargaTarjeta> recargaTarjetaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarjeta")
    private List<AvanceTarjeta> avanceTarjetaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tarjeta")
    private List<VentaTarjeta> ventaTarjetaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codigoTarjetaPasajero")
    private List<Pasajero> pasajeroList;

    public Tarjeta() {
    }

    public Tarjeta(Integer codigoTarjeta) {
        this.codigoTarjeta = codigoTarjeta;
    }

    public Tarjeta(Integer codigoTarjeta, String pinTarjeta, BigDecimal saldoTarjeta, String tipoTarjeta) {
        this.codigoTarjeta = codigoTarjeta;
        this.pinTarjeta = pinTarjeta;
        this.saldoTarjeta = saldoTarjeta;
        this.tipoTarjeta = tipoTarjeta;
    }

    public Integer getCodigoTarjeta() {
        return codigoTarjeta;
    }

    public void setCodigoTarjeta(Integer codigoTarjeta) {
        this.codigoTarjeta = codigoTarjeta;
    }

    public String getPinTarjeta() {
        return pinTarjeta;
    }

    public void setPinTarjeta(String pinTarjeta) {
        this.pinTarjeta = pinTarjeta;
    }

    public BigDecimal getSaldoTarjeta() {
        return saldoTarjeta;
    }

    public void setSaldoTarjeta(BigDecimal saldoTarjeta) {
        this.saldoTarjeta = saldoTarjeta;
    }

    public String getTipoTarjeta() {
        return tipoTarjeta;
    }

    public void setTipoTarjeta(String tipoTarjeta) {
        this.tipoTarjeta = tipoTarjeta;
    }

    public String getEstadoTarjeta() {
        return estadoTarjeta;
    }

    public void setEstadoTarjeta(String estadoTarjeta) {
        this.estadoTarjeta = estadoTarjeta;
    }

    @XmlTransient
    public List<RecargaTarjeta> getRecargaTarjetaList() {
        return recargaTarjetaList;
    }

    public void setRecargaTarjetaList(List<RecargaTarjeta> recargaTarjetaList) {
        this.recargaTarjetaList = recargaTarjetaList;
    }

    @XmlTransient
    public List<AvanceTarjeta> getAvanceTarjetaList() {
        return avanceTarjetaList;
    }

    public void setAvanceTarjetaList(List<AvanceTarjeta> avanceTarjetaList) {
        this.avanceTarjetaList = avanceTarjetaList;
    }

    @XmlTransient
    public List<VentaTarjeta> getVentaTarjetaList() {
        return ventaTarjetaList;
    }

    public void setVentaTarjetaList(List<VentaTarjeta> ventaTarjetaList) {
        this.ventaTarjetaList = ventaTarjetaList;
    }

    @XmlTransient
    public List<Pasajero> getPasajeroList() {
        return pasajeroList;
    }

    public void setPasajeroList(List<Pasajero> pasajeroList) {
        this.pasajeroList = pasajeroList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigoTarjeta != null ? codigoTarjeta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tarjeta)) {
            return false;
        }
        Tarjeta other = (Tarjeta) object;
        if ((this.codigoTarjeta == null && other.codigoTarjeta != null) || (this.codigoTarjeta != null && !this.codigoTarjeta.equals(other.codigoTarjeta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.utrans.entity.Tarjeta[ codigoTarjeta=" + codigoTarjeta + " ]";
    }
    
}
